<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="../static/easyui/jquery.min.js"></script>
<script type="text/javascript" src="../static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../static/easyui/locale/easyui-lang-zh_CN.js"></script>
<link rel="stylesheet" href="../static/easyui/themes/icon.css">
<link rel="stylesheet" href="../static/easyui/themes/metro-orange/easyui.css">

</head>
<body>
  <script type="text/javascript">
		$(function (){
			//初始化表格
			//招聘申请单
			$('#apply').datagrid({
			    url:'applycs',
			    columns:[[
					{field:'DEPTNAME',width:3,title:'需求申请部门',align:'center'},
					{field:'EMPNAME',width:2,title:'申请人',align:'center'},
					{field:'POTZW',width:2,title:'需求职位',align:'center'},
					{field:'ALTNUM',width:2,title:'需求人数',align:'center'},
					{field:'JNXXNAME',width:3,title:'技术要求',align:'center'},
					{field:'ALTFW',width:2,title:'对内/对外',align:'center'},
					{field:'ALTMINTIME',width:2,title:'开始时间',align:'center',
						formatter: function(value,row,index){
							return new Date(value).getFullYear() + '-' 
							+ (new Date(value).getMonth() + 1) + '-' 
							+ new Date(value).getDate();
						}
					},
					{field:'ALTMAXTIME',width:2,title:'截止时间',align:'center',
						formatter: function(value,row,index){
							return new Date(value).getFullYear() + '-' 
							+ (new Date(value).getMonth() + 1) + '-' 
							+ new Date(value).getDate();
						}
					},
					{field:'ALTSTAT',width:2,title:'状态',align:'center',
						formatter:function(value){
							if(value==1){
								return "未通过"
							}else if(value==2){
								return "已通过"
							}else{
								return "错误状态"
							}
						}
					},
					{field:'caozuo',width:3,title:'操作',align:'center',
						formatter:function(value,row,index){
							if(row["ALTSTAT"]==1){
								return "<span onclick='fouding()'>撤销申请</span>/\<span onclick='tongyi()'>同意申请</span>"
							}else if(row["ALTSTAT"]==2){
								return "<span onclick='dahui()'>打回申请</span>\/<span onclick='jiaru()'>加入招聘计划</span>";
							}else{
								return "错误状态"
							}
						}
					}
			    ]],
			    pagination:true,
			    pageNumber:1,
			    pageSize:10,
			    pageList:[10,20,30]
			});
			
			//查询按钮
			$("#sousuo_apply").click(function(){
				var sskuang=$("#kuang_sousuo").val();
				$("#apply").datagrid('load',{
					w:sskuang
				})				
			});
			//查看已通过的申请
			/* $(".ytgshenqing").click(function(){
				//yitongguoapply();
				 alert("sssssss");
				 $.ajax({
					type:"post",
		        	url:"yitongguodess-shenqin",
		        	data:{},
		        	success:function(){ 
		            	$("#apply").datagrid();
		            	alert("成功");
    	 			}
				}); 
			}); */
			//打开和关闭填写申请单界面
			$(".shenqing").click(function(){
				 $("#shenqingdan").window("open"); 
			});
			$(".quxiao").click(function(){
				 $("#altnumid").val("1")//人数
				 $("#heightid").val("150")//身高
				 //$("#altmintimid").val("")//开始时间
		         //$("#altmaxtimeid").val("")//截止时间
				 $("#shenqingdan").window("close"); 
			}); 
		});
		//新增
		$(function(){
			$(".queding_xzshenqin").click(function(){
				var startdate=new Date(($("#altmintimid").val()).replace(/-/g,"-"));
				var enddate=new Date(($("#altmaxtimeid").val()).replace(/-/g,"-"));
				var date = new Date();
				/* alert(startdate+"-----"+enddate); */
		        if($("#heightid").val()==""||$("#altnumid").val()==""||$("#altmintimid").val()==""||$("#altmaxtimeid").val()==""){
		        	alert("有信息尚未填写！");
		        }else if($("#heightid").val()<=140){
		        	alert("身高不可小于140CM！");
		        }else if($("#altnumid").val()<=0){
		        	alert("人数不能为0！");
		        }/* else if(startdate<date){
		        	alert("开始日期不能小于当前日期");
		        	//$("#lberror").html("<font color='red'>开始日期不能小于当前日期</font>");
		        	//return false;
		        } */else{
		        	$.ajax({
			        	type:"post",
			        	url:"xz-shenqin",
			        	data:{
			        		shenqingrenid:$("#shenqingrenid").text(),//申请人 
			        		bumenid:$("#bumenid").text(),            //部门
			        		fuzerenid:$("#fuzerenidss").val(),		//负责人
			        		potid:$("#mgmidss").val(),				//所缺职位
			                jnxxid:$("#ygjnid").val(),				//技能
			                xueliid:$("#xueliid").val(),			//学历
			                heightid:$("#heightid").val(),			//身高
			                altnumid:$("#altnumid").val(),			//人数
			                altfwid:$("#altfwid").val(),			//范围
			                altmintime:$("#altmintimid").val(),		//开始时间
			                altmaxtime:$("#altmaxtimeid").val()	    //截止时间
			        	},
			            success:function(){ 
			            	$("#apply").datagrid();
			            	/* alert("成功"); */
	    	 			}
			        }); 
		       	    $("#ageid").val("0")//年龄
		       	    $("#heightid").val("150")//身高
		       	    $("#altnumid").val("1")//人数
	 			    $('#shenqingdan').window('close');
		        }
			});
			
		});
		//同意申请单
		function tongyi(){
        	var rows=$("#apply").datagrid("getChecked");
        	/* alert(rows[0].ALTID); */
        	$.ajax({
        		type:"post",
        		url:"huoquwalt",
        		data:{waltid:rows[0].ALTID},
        		success:function(){
        			$("#apply").datagrid();
        		}
        	})
        }
		//否定申请单
		function fouding(){
			$("#fouding_queren").window("open");
		}
		$("#queding_shangchu").click(function(){
     		var rows=$("#apply").datagrid("getChecked");
		   /*  alert(rows[0].ALTID); */
		    $.ajax({
		    	type:"post",
		    	url:"foudingwalt",
		    	data:{foudingwalt:rows[0].ALTID},
		    	success:function(){
		    		$("#fouding_queren").window("close");
		    		$("#apply").datagrid();
		    	}
		    });
		});
		$("#guanbi_le").click(function(){
			$("#fouding_queren").window("close");
		});
		//打回申请
	    function dahui(){
			var rows=$("#apply").datagrid("getChecked");
			/* alert(rows[0].ALTID); */
			$.ajax({
				type:"post",
				url:"dahuiwaltes",
				data:{dahuiwaltes:rows[0].ALTID},
				success:function(){
					$("#apply").datagrid();
				}
			});
		}
		//招聘申请中
		function jiaru(){
			var rows=$("#apply").datagrid("getChecked");
			/* alert(rows[0].ALTID); */
			$.ajax({
				type:"post",
				url:"yitouguoes",
				data:{yitouguowalt:rows[0].ALTID},
				success:function(){
					$("#apply").datagrid();
				}
			});
		}
   </script>
   <script type="text/javascript" src="../static/zx/js/increment.js"></script>
<div class="full_scr bj_home">
		<div class="bj_img" style="background-image:${hopa.perPmsZts[0].ztback}"></div>
		<div class="bj_txt">
			<div class="bj_small bj_s_w7">
			   <div class="apply_box">
			      <div>
			         <div class="topbox">
			             <div class="sousuobox">
			                <input type="text" class="sousuokuang" id="kuang_sousuo" placeholder="请输入部门">
			                <input type="button" value="搜索" class="sousuoan" id="sousuo_apply">
			                <input type="button" value="填写申请" class="shenqing" id="shenqing">
			                <!-- onclick="adds('已通过的申请','oyp/alreadyplan')" -->
			                <!-- <input type="button" value="查看已通过的申请" class="ytgshenqing">  -->
			             </div>
			         </div>
			         
			         <div class="biaobox">
			            <table id="apply" class="easyui-datagrid"style="width:calc(100% - 10px);height:400px;"
			               data-options="fitColumns:true,singleSelect: true">
			              </table>
			         </div>
			      </div>
			      <div id="fouding_queren" class="easyui-window" title="删除申请" style="width:300px;height:200px"data-options="closed:true,minimizable:false,maximizable:false,collapsible:false">
					    <div class="shangchu_title"><div style="width:155px;margin:50px auto;font-size:17px;">是否确认删除该申请</div></div>
					    <div class="shangchu_an"><input type="button" id="queding_shangchu" class="qdshangchu" value="确认删除"><input type="button" id="guanbi_le" class="quxiaole" value="取消"></div>
				  </div>
			      <div id="shenqingdan" class="easyui-window" title="招聘申请" style="width:1000px;height:420px"
					    		data-options="closed:true,minimizable:false,maximizable:false,collapsible:false,modal:true">
			           <div style="width:90%;margin:0px auto;padding:20px 0px;">
			                 <div class="apply_box_leftbox">
			                     <div class="lei1" id="empidss" style="line-height:30px;height:30px;">申请人：
			                     	<span style="margin-left:20px;">${hopa.empname}</span>
			                     	<span id="shenqingrenid" style="display:none;">${hopa.empid}</span>
			                     </div>
							     <!-- <div class="lei4">年&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;龄：<input id="ageid" type="text" class="kkssa wheelable" value="0" id="altnumid"onkeyup="value=value.replace(/[^\d]/g,'')"maxlength="2" style="border-color: #21C2BF;margin-left:5px;"></div> -->
			                     <div class="lei2">所缺职位：
			                        <!-- <input type="text" class="kkssa" name="mgmid" id="mgmidss"> -->
			                        <select id="mgmidss" class="kkssa">
							        	<c:forEach items="${potnames }" var="pots">
							        		<option value="${pots.POTID }">${pots.POTZW }</option>
							        	</c:forEach>
							        </select>
			                     </div>
			                     <div class="lei2">身&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;高：
			                    	 <input id="heightid" type="text" class="kkssa wheelable" value="150" id="altnumid"onkeyup="value=value.replace(/[^\d]/g,'')"maxlength="3" style="border-color: #21C2BF;margin-left:5px;">
			                     </div>
			                     <div class="lei2">开始时间：
			                         <input  type= "text" class= "easyui-datebox" id="altmintimid" required ="required">
			                     </div>
			                 </div>
			                 <div class="apply_box_rightbox">
			                     <div class="lei1" id="deptnameid" style="line-height:30px;height:30px;">需求部门：<span>${hopa.perPmsStms[0].perPmsDept.deptname}</span><span id="bumenid" style="display:none;">${hopa.perPmsStms[0].perPmsDept.deptid}</span></div>
			                     <div class="lei2">技术要求：
			                        <!-- <input type="text" class="kkssa" name="empname" id="ygjnid"> -->
			                        <select id="ygjnid" class="kkssa">
							        	<c:forEach items="${jnxxname }" var="jnxx">
							        		<option  value="${jnxx.JNXXID }">${jnxx.JNXXNAME }</option>
							        	</c:forEach>
							        </select>
			                     </div>
			                     <div class="lei2">所缺人数：<input id="altnumid" type="text" class="kkssa wheelable" value="1" id="altnumid"onkeyup="value=value.replace(/[^\d]/g,'')" style="border-color: #21C2BF;margin-left:5px;"></div>
			                     <div class="lei2">截止时间：
			                         <input  type= "text" class= "easyui-datebox" id="altmaxtimeid" required ="required">
			                     </div>
			                 </div> 
			                 <div class="apply_box_rightbox">
			                     <div class="lei1">负责人：
			                       <select id="fuzerenidss" class="kkssa" style="font-size:17px;margin-left:15px;">
						  	           <c:forEach items="${fuzerennames }" var="fuzeren">
						  	           	  <option value="${fuzeren.EMPID }">${fuzeren.EMPNAME }</option>
						  	           </c:forEach>
						  	       </select>
			                     </div>
			                     <div class="lei2">
			                        <span>所需学历：</span>
							        <select class="kkssa" id="xueliid">
							         	<c:forEach items="${xueliname }" var="xueli">
							              	<option value="${xueli.RFSID }">${xueli.RFSNAME }</option>
							             </c:forEach>
							         </select>
			                     </div>
			                     <div class="lei2">招聘范围：
			                         <select id="altfwid" class="kkssa">
							             <option>对外</option>
							             <option>对内</option>
							         </select>
			                     </div>
			                     <div class="lei8">
			                         <input type="button" class="queding_xzshenqin" value="确定">
			                         <input type="button" class="quxiao" value="取消">  
			                     </div>
			                 </div>
			           </div>
			      </div>
			   </div>
   		</div>
	</div>
</div>
</body>
</html>